package com.bus.boot.manager.assist.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bus.boot.dao.assist.BusGuestbookExtDao;
import com.bus.boot.entity.assist.BusGuestbook;
import com.bus.boot.entity.assist.BusGuestbookExt;
import com.bus.boot.manager.assist.BusGuestbookExtMng;
import com.bus.common.hibernate4.Updater;

@Service
@Transactional
public class BusGuestbookExtMngImpl implements BusGuestbookExtMng {
	public BusGuestbookExt save(BusGuestbookExt ext, BusGuestbook guestbook) {
		guestbook.setExt(ext);
		ext.setGuestbook(guestbook);
		ext.init();
		dao.save(ext);
		return ext;
	}

	public BusGuestbookExt update(BusGuestbookExt ext) {
		Updater<BusGuestbookExt> updater = new Updater<BusGuestbookExt>(ext);
		BusGuestbookExt entity = dao.updateByUpdater(updater);
		entity.blankToNull();
		return entity;
	}

	private BusGuestbookExtDao dao;

	@Autowired
	public void setDao(BusGuestbookExtDao dao) {
		this.dao = dao;
	}
}